<?php


namespace App\Http\Controllers\Admin;


use App\Http\Controllers\Controller;
use App\Models\Game\Token;
use App\Models\Setting;
use App\Services\SettingService;
use App\Utils\ResponseUtil;

class SettingController extends Controller
{
    private SettingService $settingService;

    /**
     * SettingController constructor.
     * @param SettingService $settingService
     */
    public function __construct(SettingService $settingService)
    {
        $this->settingService = $settingService;
    }

    public function getByName(){
        $name = request()->get('name');
        $data = $this->settingService->getByName($name);
        return ResponseUtil::success($data);
    }

    public function getToken(){
        $data = Token::query()->first();
        return ResponseUtil::success($data);
    }
    public function setByName(){
        $name = request()->get('name');
        $val = request()->get('val');
        $this->settingService->setByName($name,$val);
        return ResponseUtil::success();
    }

    public function list(){
        $data = Setting::query()->get();
        return ResponseUtil::success($data);
    }

}
